package com.jt.service.factory;

import com.jt.service.FeignConsumerService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 基于FeignConsumerService接口调用时出现服务中断，超时等问题
 */
@Component
public class ProviderFallbackFactory implements FallbackFactory<FeignConsumerService> {
    /**
     * 此方法会在FeignConsumerService接口调用时，出现异常时执行
     * @param throwable 用于接受异常
     * @return
     */
    @Override
    public FeignConsumerService create(Throwable throwable) {
        return (msg) -> {
            return "服务维护中，请稍等片刻....";
        };
    }
}
